<?php include "header.php";?>
	<div id="all">
		<?php
			if($lang == 0){
				$sqlArticle = "Select id,menuid, vi_title as title, vi_content as content from tblarticle where id =" .$articleID; 
			}else{
				$sqlArticle = "Select id,menuid, en_title as title, en_content as content from tblarticle where id =" .$articleID; 
			}
			$rsArticle = mysql_query($sqlArticle) or die(mysql_error);
			$article = mysql_fetch_object($rsArticle);
		?>
		<div id="main">
			<div id="m-left">
				<?php
				$sqlMenu = "Select parent_id from tblmenu where id=".$article->menuid;
				$rsMenu = mysql_query($sqlMenu) or die(mysql_error());
				if(mysql_num_rows($rsMenu)>0){
					$menu = mysql_fetch_object($rsMenu);
					$sqlParentMenu =  "Select id, vi_name, en_name from tblmenu where id= ".$menu->parent_id." order by tblmenu.order";
					$parentMenu = mysql_fetch_object(mysql_query($sqlParentMenu)) or die(mysql_error());
					if($parentMenu->parent_id != 0){
						$sqlParentMenu =  "Select id, vi_name, en_name from tblmenu where id= ".$parentMenu->parent_id." order by tblmenu.order";
						$parentMenu = mysql_fetch_object(mysql_query($sqlParentMenu)) or die(mysql_error());
					}
					if($lang == 0){
						$sqlChildMenus = "Select id,url, vi_name as name from tblmenu where parent_id= ".$parentMenu->id." order by tblmenu.order";
					}else{
						$sqlChildMenus = "Select id,url, en_name as name from tblmenu where parent_id= ".$parentMenu->id." order by tblmenu.order";
					}
				}else{
					if($lang == 0){
						$sqlChildMenus = "Select id, vi_name as name from tblmenu where parent_id= 0 order by tblmenu.order";
					}else{
						$sqlChildMenus = "Select id, en_name as name from tblmenu where parent_id= 0 order by tblmenu.order";
					}
				}
				
				
				$rsChildMenus = mysql_query($sqlChildMenus) or die(mysql_error());
				?>
				<div class="sidebar">
					<div class="title">
												
						<?php
							if(mysql_num_rows($rsMenu)== 0){
								if($lang == 0){ 
									echo "Danh mục";
								}else{
									echo "Menus";
								}
							}else{
								if($lang == 0){ 
									if($parentMenu->parent_id != 0){ 
									?>
									<a href="<?php echo ROOT_PATH."/m/".$parentMenu->parent_id;?>"><?php echo $parentMenu->name;?></a>
									<?php
									}
									else {
										echo $parentMenu->name;
									}
								}else{
									echo $parentMenu->en_name;
								}
							}
						?>
					</div>
					<!--
					<div class="container">
						<ul  class="menu-left">
						<?php
							while($childMenu = mysql_fetch_object($rsChildMenus)){
								echo "<li><a href='".(($childMenu->url =="")? (ROOT_PATH."/m/".$childMenu->id) : ROOT_PATH.$childMenu->url)."'>".$childMenu->name."</a></li>";					
							}
						?>
						</ul>
					</div>-->
					<div class="container">
						<ul class="menu-left">
						
	<script type="text/javascript" src="../ddaccordion.js"></script>
<script type="text/javascript">
ddaccordion.init({headerclass:"submenuheader",contentclass:"submenu",revealtype:"mouseover",mouseoverdelay:150,collapseprev:true,defaultexpanded:[],onemustopen:false,animatedefault:false,persiststate:true,toggleclass:["",""],togglehtml:["suffix","",""],animatespeed:"fast",oninit:function(headers,expandedindices){},onopenclose:function(header,index,state,isuseractivated){}})</script>
							<div class="glossymenu">
						<?php
								$arrChildMenu = array();
								while($childMenu = mysql_fetch_object($rsChildMenus)) {
									$arrChildMenu[] = $childMenu;
								}
								if($menu->parent_id !=0){
								
									if($lang == 0){
										$sqlChildMenus1 = "Select id, vi_name as name, url from tblmenu where parent_id =" .$parentMenu->id." order by tblmenu.order"; 
									}else{
										$sqlChildMenus1 = "Select id, en_name as name, url from tblmenu where parent_id =" .$parentMenu->id." order by tblmenu.order"; 
									}
									
									$rsChildMenus1 = mysql_query($sqlChildMenus1) or die(mysql_error);
									while($childMenu1 = mysql_fetch_object($rsChildMenus1)) {
									
										echo "<li>";
									?>								

	<a headerindex="11" class="menuitem submenuheader" href="<?php echo (($childMenu1->url =="")? (ROOT_PATH."/m/".$childMenu1->id) : ROOT_PATH.$childMenu1->url);?>"><?php echo $childMenu1->name;?></a> 
	<?php 
		if($lang == 0){
				$sqlChildMenus2 = "Select id, vi_name as name, url from tblmenu where parent_id =" .$childMenu1->id." order by tblmenu.order"; 
			}else{
				$sqlChildMenus2 = "Select id, en_name as name, url from tblmenu where parent_id =" .$childMenu1->id." order by tblmenu.order"; 
			}
			$rsChildMenus2 = mysql_query($sqlChildMenus2) or die(mysql_error);
			if ($rsChildMenus2) {					
								
		?>
		<div contentindex="11" class="submenu">
		<ul>
		<?php 
			while($childMenu2 = mysql_fetch_object($rsChildMenus2)) {						
								
		?>
			<li><a href="<?php echo (($childMenu2->url =="")? (ROOT_PATH."/m/".$childMenu2->id) : ROOT_PATH.$childMenu2->url);?>"><?php echo $childMenu2->name;?></a></li>		
<?php 
}
?>			
		</ul> 
	</div>		

									<?php
									}									
									echo "</li>";									
									}
								}
								else{
									foreach($arrChildMenu as $childMenu){
									echo "<li>";
									$urllink1= ROOT_PATH."/m/".$childMenu->id;
									?>								<!-- onclick="window.open('<?php echo $urllink1;?>')"-->

	<a headerindex="11" class="menuitem submenuheader" href="<?php echo (($childMenu->url =="")? (ROOT_PATH."/m/".$childMenu->id) : ROOT_PATH.$childMenu->url);?>" ><?php echo $childMenu->name;?></a>
	<?php 
		if($lang == 0){
				$sqlChildMenus2 = "Select id, vi_name as name, url from tblmenu where parent_id =" .$childMenu->id." order by tblmenu.order"; 
			}else{
				$sqlChildMenus2 = "Select id, en_name as name, url from tblmenu where parent_id =" .$childMenu->id." order by tblmenu.order"; 
			}
			$rsChildMenus2 = mysql_query($sqlChildMenus2) or die(mysql_error);
			if ($rsChildMenus2) {	
		?>
		<div contentindex="11" class="submenu">
		<ul>
		<?php 
			while($childMenu2 = mysql_fetch_object($rsChildMenus2)) {														
		?>	<li><a href="<?php echo (($childMenu2->url =="")? (ROOT_PATH."/m/".$childMenu2->id) : ROOT_PATH.$childMenu2->url);?>"><?php echo $childMenu2->name;?></a></li>	
		<?php } ?>			
		</ul> 
	</div>					<?php
									}									
									echo "</li>";
									}
									?></div><?php
								}
								
							?>
							
						</ul>
					</div>
				</div>
			</div>
			<div id="m-mid">
				<div class="title">
					<?php echo $article->title;?>
				</div>
				<div class="content">
					<?php echo $article->content;?>
				</div>
			</div>
			<div id="m-right">
			
				<div class="sidebar">
					<?php include "newest.php";?>
				</div><!-- end of sidebar -->
				<?php include "loginlink.php";?>
			</div>
				
			<div class="clear-fix"></div>
		</div><!--  end of main -->
		<?php include "footer.php";?>
	</div>
</body>
</html>